package com.lightboat.common.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StreamUtils;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

/**
 * 启动打印
 */
@Slf4j
public class BannerPrint {
    public static void print(String resourceName) {
        if (resourceName == null) {
            return;
        }
        try (InputStream inputStream = BannerPrint.class.getClassLoader().getResourceAsStream(resourceName)) {
            String string = StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);
            log.info(StringUtils.format("\n{}\n", string));
        } catch (IOException e) {
            e.fillInStackTrace();
        }
    }
}
